package com.aft.terra.modules.basic.model;

import java.util.HashMap;

import java.util.List;
import java.util.Map;

import com.aft.terra.app.Constants;
import com.aft.terra.common.utils.RedisKit;
import com.aft.terra.modules.basic.model.base.BaseConfig;
import com.jfinal.plugin.redis.Cache;

/**
 * 系统初始化模型
 */
public class Config extends BaseConfig<Config> {
	
	/** 
	 * @Fields serialVersionUID: 
	 */
	  	
	private static final long serialVersionUID = 4978616067125610028L;
	
	public static final Config dao = new Config();
	
	/**
	 * 初始化系统参数
	 * 服务启动后自动设置前台JS版本号
	 * @author Mandarava
	 * @return
	 */
	public void config(){
		String sql = "SELECT * FROM t_config";
		List<Config> configList =  find(sql);
		Map<String,String> map = new HashMap<String,String>();
		for (Config config : configList) {
			map.put(config.getKey(), config.getValue());
		}
		
		Cache cache = RedisKit.getCache();
		cache.set(Constants.GAME_CONFIG_PARAMS, map);
	}
}
